from flask import Blueprint, render_template, request
from exts.db import dbexec
screen = Blueprint('admin', __name__)


@screen.route('/')
def index():
    sql = "SELECT value From config where name = 'title' " \
          "UNION " \
          "SELECT value From config where name = 'lefttext1' " \
          "UNION " \
          "SELECT value From config where name = 'lefttext2'"\
          "UNION " \
          "SELECT value From config where name = 'middletext1'"\
          "UNION " \
          "SELECT value From config where name = 'middletext2'"\
        "UNION " \
        "SELECT value From config where name = 'righttext1'" \
        "UNION " \
        "SELECT value From config where name = 'righttext2'" \
        "UNION " \
        "SELECT value From config where name = 'righttext3'"

    res= dbexec(sql)
    data={
        'title':res[0][0],
        'lefttext1':res[1][0],
        'lefttext2':res[2][0],
        'middletext1':res[3][0],
        'middletext2': res[4][0],
        'righttext1':res[5][0],
        'righttext2':res[6][0],
        'righttext3':res[7][0],

    }
    return render_template('index.html',data=data)


@screen.route('/add')
def add():
    return 'admin_add'


@screen.route('/show')
def show():
    return 'admin_show'
